<?php

namespace app\admin\controller;

use app\admin\service\SystemService;
use app\common\util\ErrorCode;

class SystemController extends CommonController
{
    public function getConfigInfo($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        switch ($_type){
            case "wxApp": // 获取微信小程序配置信息
                $method = "getWxAppInfo";
                break;
            case "share": // 获取微信小程序分享信息
                $method = "getWxAppQr";
                break;
            case "sms": //获取短信配置信息
                $method = "getSmsInfo";
                break;
            case "wxMessage": //获取微信模板消息配置信息
                $method = "getWxMessageInfo";
                break;
            case "withdraw": //提现
                $method = "getWithdrawInfo";
                break;
            case "carRemarks": //跨境专车接送线路备注
                $method = "getCarRemarksInfo";
                break;
            case "airportRemarks": //机场线路备注
                $method = "getAirportRemarksInfo";
                break;
            case "enterpriseRemarks": //巴士线路备注
                $method = "getEnterpriseRemarksInfo";
                break;
            case "vehicleRemarks": //包车线路备注
                $method = "getVehicleRemarksInfo";
                break;
            case "aboutUs": //关于我们
                $method = "getAboutUsInfo";
                break;
            case "loginConf": //登录页的配置项
                $method = "getLoginConfInfo";
                break;
            case "customerService": //获取客服的配置项
                $method = "getCustomerServiceInfo";
                break;
            case "ruleContent": // 获取退改规则
                $method = "getRuleContent";
                break;
            case "tc": // 获取腾讯云配置
                $method = "getTc";
                break;
            default:
                return $this->returnData = ErrorCode::$errorCode["fail"];
                break;
        }
        $service = $this->app->invokeClass(SystemService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->{$method}();
        return $this->return_result($this->returnData);
    }

    public function getSaveConfig($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        switch ($_type){
            case "wxApp": // 获取微信小程序配置信息
                $method = "getSaveWxApp";
                break;
            case "share": // 获取微信小程序分享信息
                $method = "getSaveSharePicture";
                break;
            case "sms": // 获取短信配置信息
                $method = "getSaveSms";
                break;
            case "wxMessage": // 获取微信模板消息配置信息
                $method = "getSaveWxMessage";
                break;
            case "withdraw": //提现
                $method = "getSaveWithdraw";
                break;
            case "carRemarks": //跨境专车接送线路备注
                $method = "getSaveCarRemarks";
                break;
            case "airportRemarks": //机场线路备注
                $method = "getSaveAirportRemarks";
                break;
            case "enterpriseRemarks": //巴士线路备注
                $method = "getSaveEnterpriseRemarks";
                break;
            case "vehicleRemarks": //包车线路备注
                $method = "getSaveVehicleRemarks";
                break;
            case "aboutUs": //关于我们
                $method = "getSaveAboutUs";
                break;
            case "loginConf": //登录页的配置项
                $method = "getSaveLoginConf";
                break;
            case "customerService": //保存客服的配置项
                $method = "getSaveCustomerService";
                break;
            case "ruleContent": // 保存退改规则
                $method = "getSaveRuleContent";
                break;
            case "tc": // 保存腾讯云配置
                $method = "getSaveTc";
                break;
            default:
                return $this->returnData = ErrorCode::$errorCode["fail"];
                break;
        }
        $service = $this->app->invokeClass(SystemService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->{$method}();
        return $this->return_result($this->returnData);
    }

    public function getSiteInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(SystemService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getSiteInfo();
        return $this->return_result($this->returnData);
    }
}
